<?php
require_once("../config.php"); 
require_once("../model/DB.php");
require_once("../model/Archive.php");

$arr = array();
if($_POST['id']!=0){
	if(Archive::editArchive($_POST['id'],$_POST['desc'],$_POST['kid'])){
		$arr['msg'] = "saved";
		$arr['id'] = $_POST['id'];
	}	
}
else{
	if(Archive::addArchive($_POST['desc'],$_POST['kid'])){
		$arr['msg'] = "added";
		$id = Archive::getLastInsert();
		$arr['id'] = $id['id'];
	}
}

print json_encode($arr);
?>